Project - Developing Data Products

Mahir Musleh

July 30, 2019

Project Goals

-Take a look how some Canadian provinces’ population changed overtime
-Take a look at some regression about what affects the Canadian GNI per capita
We will be using shiny application to create a slider to change the quarter to produce te desired effect on the interactive map. We also will create two additional tabs to inform people about the regression analysis done and plot created on GNI per capita.

Population eh!

Codes for interactive map generation

prov.pop <- fread("./can_pop.csv",stringsAsFactors = FALSE)

colnames(prov.pop)[1] <- "Province"

prov.pop[] <- lapply(prov.pop, function(x) gsub(",","",x))

prov.pop[] <- lapply(prov.pop, function(x) as.character(x))
prov.pop[,2:272] <- lapply(prov.pop[,2:272], function(x) as.numeric(x))

region <- readOGR("./src/ref/ne_50m_admin_1_states_provinces_lakes", encoding='UTF-8')


prov.pop %>% leaflet() %>% 
    addTiles() %>% 
    setView(-100, 62,  zoom = 3) %>% 
    addPolygons(data = subset(region, name %in% c("Quebec","British Columbia", "Alberta", "Saskatchewan", "Manitoba", "Ontario", "Quebec", "New Brunswick", "Prince Edward Island", "Nova Scotia", "Newfoundland and Labrador", "Yukon", "Northwest Territories", "Nunavut")), 
                fillColor = topo.colors(15, alpha = NULL),
                weight = 1) %>%
    addCircles(popup = paste0(prov.pop$Province),
               weight = 4,
               radius = (prov.pop$`1952 Q1`)*.015,color = "red")

Population eh!

The shiny app will have a slider to change the quarter of the year and the population change, represented by the size of the circle, will change.

Summary aqnd plot of the linear regression model for GNI per capita

Data: World Bank Databank

Values were converted into logarithm form first

Summary


Call:
lm(formula = GNI ~ . - Year, data = indicator.1)

Residuals:
      Min        1Q    Median        3Q       Max 
-0.081389 -0.017057  0.001302  0.024043  0.072976 

Coefficients:
             Estimate Std. Error t value Pr(>|t|)    
(Intercept) -10.41019    0.37103 -28.058  < 2e-16 ***
EXP          -0.38919    0.09553  -4.074 0.000195 ***
IMP           0.54996    0.12463   4.413 6.75e-05 ***
CONS         -0.22028    0.21774  -1.012 0.317356    
GEXP          0.65077    0.17751   3.666 0.000673 ***
INV           0.20923    0.05560   3.763 0.000503 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.03616 on 43 degrees of freedom
Multiple R-squared:  0.9976,    Adjusted R-squared:  0.9973 
F-statistic:  3562 on 5 and 43 DF,  p-value: < 2.2e-16

Plot